package com.zzj.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzj.entity.NurseSchedule;
import com.zzj.mapper.NurseScheduleMapper;
import com.zzj.service.INurseScheduleService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 医护排班 服务实现类
 * </p>
 *
 * @author zzj
 * @since 2023-05-12
 */
@Service
public class NurseScheduleServiceImpl extends ServiceImpl<NurseScheduleMapper, NurseSchedule> implements INurseScheduleService {

    @Override
    public boolean book(int id) {
      return this.lambdaUpdate()
                .eq(NurseSchedule::getId, id)
                .setSql("appointment_num = appointment_num + 1")
                .setSql("usable_num = usable_num - 1")
                .update();
    }

    @Override
    public boolean cancel(int id) {
        return this.lambdaUpdate()
                .eq(NurseSchedule::getId, id)
                .setSql("appointment_num = appointment_num - 1")
                .setSql("usable_num = usable_num + 1")
                .update();
    }
}
